package controller;

import java.util.HashMap;
import java.util.Map;

/*
 * Attribute - request Scope에 binding할 속성.
 * and
 * View - 응답할 View에 대한 정보를 가질 DO(Domain Object).
 */
public class AttributeAndView {
	//View
	private boolean redirect; //true : 리다이렉트 방식, false : 디스패치 방식
	private String url; // 응답할 View의 url.
	
	//Request Scope에 binding 할 Attribute관련 instance변수
	private Map<String, Object> attributes;
	
	//request scope 에 넣을 Attribute가  여러개인 경우.
	public AttributeAndView(boolean redirect, String url, Map<String,Object> attribute) {
		this.redirect = redirect;
		this.url = url;
		this.attributes = attributes;
	}
	
	//request scope에 넣을 Attribute가 한개인 경우
	public AttributeAndView(boolean redirect, String url, String name, Object value) {
		this.redirect = redirect;
		this.url = url;
		attributes = new HashMap<String, Object>();
		attributes.put(name, value);
	}
	
	
	public AttributeAndView(){}
	
	public AttributeAndView(boolean redirect, String url) {
		this.redirect = redirect;
		this.url = url;
	}

	public boolean isRedirect() {
		return redirect;
	}

	public void setRedirect(boolean redirect) {
		this.redirect = redirect;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	
	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
	}

	@Override
	public String toString() {
		return "AttributeAndView [redirect=" + redirect + ", url=" + url + "]";
	}
	
}
